/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cratos.xxgram.platf.message;


import java.util.List;

import javax.persistence.Column;

import org.redkale.util.Comment;

import com.cratos.xxgram.platf.sysnotice.SystemNotice;
import com.cratos.xxgram.platf.sysnotice.SystemUserNotice;

/**
 * 内容类消息
 *
 * @author SquRab
 */
public abstract class BasicContent extends BaseContent {

   	@Comment("文字消息")
    public static final short OBJ_TEXT_MESSAGE = 1001;

    @Comment("语音消息")
    public static final short OBJ_VPOICE_MESSAGE = 1002;

    @Comment("文件类的消息")
    public static final short OBJ_FILE_MESSAGE = 1003;

    
    @Comment("小视频消息")
    public static final short OBJ_SIGTH_MESSAGE = 1004;

    @Comment("位置消息")
    public static final short OBJ_LBS_MESSAGE = 1005;

    @Comment("图文消息")
    public static final short OBJ_IMAGE_TEXT_MESSAGE = 1006;

    @Comment("群聊自定义消息")
    public static final short LOCAL_OBJ_GROUP_MESSAGE = 1007;

    @Comment("文件类分享转发")
    public static final short OBJ_SHARE_FILE_MESSAGE = 1008;
    
    @Comment("音频消息")
    public static final short OBJ_AUDIO_MESSAGE = 1009;
     
    @Comment("图片消息")
    public static final short OBJ_IMAGE_MESSAGE = 1010;
     
    @Comment("对话框提示消息")
    public static final short OBJ_MESSAGE_TIP = 1011;
   
    @Comment("分享名片")
    public static final short OBJ_SHARE_CARDS_MESSAGE = 1012;
    
    @Comment("融云语音通话消息")
    public static final short OBJ_RONGCLOUD_VOICE_MESSAGE = 1013;
    
    @Comment("系统公告")
    public static final short OBJ_SYSNOTICE_MESSAGE = 1014;
    
    @Comment("消息合并转发")
    public static final short OBJ_MERAGE_FROWORDMESSAGE = 1015;
    
    /**
     * 文件类型消息
     *
     * @author SquRab
     */
    public static class FileMessage extends BasicContent {

        @Comment("文件类消息")
        public transient static final short TYPE = OBJ_FILE_MESSAGE;

        @Comment("文件名称")
        private String name;

        @Comment("文件大小 bytes")
        private int size;

        @Comment("文件类型。")
        private String type; //txt

        @Comment("文件地址")
        private String fileUrl; // http://www.demo.com/am.ind

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getSize() {
            return size;
        }

        public void setSize(int size) {
            this.size = size;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getFileUrl() {
            return fileUrl;
        }

        public void setFileUrl(String fileUrl) {
            this.fileUrl = fileUrl;
        }
    }

    @Comment("图片消息")
    public static class ImageMessage extends BasicContent {

        @Comment("文件类消息")
        public transient static final short TYPE = OBJ_IMAGE_MESSAGE;

        @Comment("文件名称")
        private String name;

        @Comment("文件大小 bytes")
        private int size;

        @Comment("文件类型。")
        private String type; //txt

        @Comment("文件地址")
        private String fileUrl; // http://www.demo.com/am.ind

        @Comment("缩略图地址")
        private String thumbnailUrl; // http://www.demo.com/am.ind
        
        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getSize() {
            return size;
        }

        public void setSize(int size) {
            this.size = size;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getFileUrl() {
            return fileUrl;
        }

        public void setFileUrl(String fileUrl) {
            this.fileUrl = fileUrl;
        }

        public String getThumbnailUrl() {
            return thumbnailUrl;
        }

        public void setThumbnailUrl(String thumbnailUrl) {
            this.thumbnailUrl = thumbnailUrl;
        }
        
    }
    
    /**
     * 小视频消息¶
     *
     * @author SquRab
     */
    public static class SightMessage extends BasicContent {

        @Comment("小视频消息")
        public transient static final short TYPE = OBJ_SIGTH_MESSAGE;

        @Comment("上传到文件服务器的小视频地址。")
        private String fileUrl;

        @Comment("第一帧缩略图")
        private String picUrl;

        @Comment("视频时长，单位：秒。")
        private int duration;

        @Comment("视频大小单位 bytes。")
        private int size;

        @Comment("发送端视频的文件名，小视频文件格式为 .mp4。")
        private String name;

        public String getFileUrl() {
            return fileUrl;
        }

        public void setFileUrl(String fileUrl) {
            this.fileUrl = fileUrl;
        }

        public String getPicUrl() {
            return picUrl;
        }

        public void setPicUrl(String picUrl) {
            this.picUrl = picUrl;
        }
        
        
        public int getDuration() {
            return duration;
        }

        public void setDuration(int duration) {
            this.duration = duration;
        }

        public int getSize() {
            return size;
        }

        public void setSize(int size) {
            this.size = size;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

    }

    /**
     * 音频消息¶
     * @author SquRab
     */
    public static class AudioMessage extends BasicContent {

        @Comment("音频消息")
        public transient static final short TYPE = OBJ_AUDIO_MESSAGE;

        @Comment("上传到文件服务器的小视频地址。")
        private String fileUrl;

        @Comment("视频时长，单位：秒。")
        private int duration;

        @Comment("视频大小单位 bytes。")
        private int size;

        @Comment("发送端视频的文件名，小视频文件格式为 .mp4。")
        private String name;

        public String getFileUrl() {
            return fileUrl;
        }

        public void setFileUrl(String fileUrl) {
            this.fileUrl = fileUrl;
        }

        public int getDuration() {
            return duration;
        }

        public void setDuration(int duration) {
            this.duration = duration;
        }

        public int getSize() {
            return size;
        }

        public void setSize(int size) {
            this.size = size;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

    }
    /**
     *
     * @author SquRab
     */
    @Comment("文字消息")
    public static class TextMessage extends BasicContent {

        @Comment("文本消息")
        public transient static final short TYPE = OBJ_TEXT_MESSAGE;

        @Column(comment = "文字消息的文字内容，包括表情。")
        public String content = "";

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public TextMessage(String content) {
            this.content = content;
        }

        public TextMessage() {
        }
    }

    /**
     * 位置消息¶ 用来发送地理位置消息，客户端收到消息后计入未读消息数、进行存储。
     */
    public static class LocationMessage extends BasicContent {

        @Comment("位置消息")
        public transient static final short TYPE = OBJ_LBS_MESSAGE;

        
        @Comment("表示位置图片缩略图，格式为 JPG，以 Base64 进行 Encode 后需要将所有 \\r\\n 和 \\r 和 \\n 替换成空。")
        private String content;

        @Comment("位置的纬度值。")
        private double latitude;

        @Comment("位置的经度值。")
        private double longitude;

        @Comment("检索地址")
        private String poi;

        @Comment("具体位置信息")
        private String address;
        
        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public double getLatitude() {
            return latitude;
        }

        public void setLatitude(double latitude) {
            this.latitude = latitude;
        }

        public double getLongitude() {
            return longitude;
        }

        public void setLongitude(double longitude) {
            this.longitude = longitude;
        }

        public String getPoi() {
            return poi;
        }

        public void setPoi(String poi) {
            this.poi = poi;
        }

		public String getAddress() {
			return address;
		}

		public void setAddress(String address) {
			this.address = address;
		}

        
    }

    /**
     * 图文消息
     */
    public static class RichContentMessage extends BasicContent {

        @Comment("图文消息")
        public transient static final short TYPE = OBJ_IMAGE_TEXT_MESSAGE;

        @Comment("标题")
        private String title;

        @Comment("消息的文字内容。")
        private String content;

        @Comment("消息中图片地址，图片尺寸为：120 x 120 像素。")
        private String imageUri;

        @Comment("点击图片消息后跳转的 URL 地址。")
        private String url;

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public String getImageUri() {
            return imageUri;
        }

        public void setImageUri(String imageUri) {
            this.imageUri = imageUri;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }
    }

    @Comment("群聊自定义消息")
    public static class GroupContentMessage extends BasicContent {

        @Comment("群聊消息")
        public transient static final short TYPE = LOCAL_OBJ_GROUP_MESSAGE;

        @Comment("消息内容")
        public String content;

        @Comment("@ 功能类型，1 表示 @ 所有人、2 表示 @ 指定用户。（必传）")
        short type;

        @Comment("指定用户列表，type 为 2 时有效，为 1 时 userIdList 可以为空。（非必传）")
        String[] userIdList;

        public int getType() {
            return type;
        }

        public void setType(short type) {
            this.type = type;
        }

        public String[] getUserIdList() {
            return userIdList;
        }

        public void setUserIdList(String[] userIdList) {
            this.userIdList = userIdList;
        }
            
        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }
        
    }
    
    @Comment("文件分享")
    public static class ShareFileMessage extends BasicContent {

        @Comment("文件分享消息类型")
        public transient static final short TYPE = OBJ_SHARE_FILE_MESSAGE;
        
        @Comment("消息发送接收对象类型 用户")
        public static final short USER_TYPE = 10;
        
        @Comment("消息发送接收对象类型 群")
        public static final short GROUP_TYPE = 20;
        
        @Comment("文件名称")
        private String name;

        @Comment("文件大小 bytes")
        private int size;

        @Comment("文件类型。")
        private String type; //txt

        @Comment("文件地址")
        private String fileUrl; // http://www.demo.com/am.ind

        @Comment("接收方类型  10 用户  20 群")
        private short fromType;
        
        @Comment("接收方类型  10 用户  20 群")
        private short targetType;

        public short getFromType() {
            return fromType;
        }

        public void setFromType(short fromType) {
            this.fromType = fromType;
        }

        
        public short getTargetType() {
            return targetType;
        }

        public void setTargetType(short targetType) {
            this.targetType = targetType;
        }
        
        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getSize() {
            return size;
        }

        public void setSize(int size) {
            this.size = size;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getFileUrl() {
            return fileUrl;
        }

        public void setFileUrl(String fileUrl) {
            this.fileUrl = fileUrl;
        }
    }
    
    @Comment("对话框提示")
    public static class TipMessage extends BasicContent {
        @Comment("文本消息")
        public transient static final short TYPE = OBJ_MESSAGE_TIP;

        @Comment("添加好友成功 已经是好友可以开始聊天")
        public static final short USER_ADDFRIEND_TP = 100;
        
        @Comment("创建群提示")
        public static final short GROUP_CREATEGROUP_TP = 200;
        
        @Comment("退出群提示")
        public static final short GROUP_QUITGROUP_TP = 201;
        
        @Comment("踢人出群提示")
        public static final short GROUP_KICKGROUP_TP = 202;
        
        @Comment("拉人进入出群提示")
        public static final short GROUP_PULLGROUP_TP = 203;
        
        @Comment("主动加入出群提示")
        public static final short GROUP_JOINGROUP_TP = 204;
        
        @Comment("解散群提示")
        public static final short GROUP_DISMISSGROUP_TP = 205;
        
        @Comment("全员禁言")
        public static final short GROUP_FORBIT_WORD_TP = 206;
         
        @Comment("更新群名称")
        public static final short GROUP_UPDATE_NAME_TP = 207;
         
        @Comment("更新群公告")
        public static final short GROUP_UPDATE_NOTICE_TP = 208;
         
        @Comment("更新群类型")
        public static final short GROUP_UPDATE_GROUPTYPE_TP = 209;
        
        @Comment("tip消息类型提示")
        private short type;
        
        @Column(comment = "文字消息的文字内容，包括表情。")
        public String content = "";

        @Comment("被操作的用户id")
        public int [] targetUserids;
        
        public short getType() {
            return type;
        }

        public void setType(short type) {
            this.type = type;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public int[] getTargetUserids() {
            return targetUserids;
        }

        public void setTargetUserids(int[] targetUserids) {
            this.targetUserids = targetUserids;
        }
        
        
    }
    
    @Comment("分享用户，群 名片通知")
    public static final class ShareCardNotify extends BasicContent  {
      

      @Comment("分享名片")
      public transient static final short TYPE = OBJ_SHARE_CARDS_MESSAGE;
      
      @Comment("群类型为20")
      public static final short TARGET_GROUP = 20;
      
      @Comment("用户类型为10")
      public static final short TARGET_USER = 10;
       
      @Comment("10 用户  20  群 被分享对象的类型")
      public short targettype;
      
      @Comment("被分享的群或者用户名称")
      private String targetname;
      
      @Comment("被分享的群或者用户ID")
      private int targetid;

      @Comment("群名片头像")
      private String targetPic;
      
      public short getTargettype() {
          return targettype;
      }

      public void setTargettype(short targettype) {
          this.targettype = targettype;
      }

      public String getTargetname() {
          return targetname;
      }

      public void setTargetname(String targetname) {
          this.targetname = targetname;
      }

      public int getTargetid() {
          return targetid;
      }

      public void setTargetid(int targetid) {
          this.targetid = targetid;
      }

      public String getTargetPic() {
          return targetPic;
      }

      public void setTargetPic(String targetPic) {
          this.targetPic = targetPic;
      }
      
   }
    
    @Comment("融云语音通话")
    public static final class RongCloudVoiceMessage extends  BasicContent {
        
      @Comment("融云语音通话")
      public transient static final short TYPE = OBJ_RONGCLOUD_VOICE_MESSAGE;
      
      @Comment("接听")
      public static final short RESP_ACCEPT = 10;
      
      @Comment("拒绝接听")
      public static final short RESP_REFAUSE = 20;
      
      @Comment("融云语音通话时长，单位：秒。")
      private int duration;
      
      @Comment("响应策略  10 接听 20 拒绝接听")
      private short respstatus;
      
        public int getDuration() {
            return duration;
        }

        public void setDuration(int duration) {
            this.duration = duration;
        }

        public short getRespstatus() {
            return respstatus;
        }

        public void setRespstatus(short respstatus) {
            this.respstatus = respstatus;
        }
      
      
    }
    
    @Comment("系统公告")
    public static final class SysNoticeMessage extends BasicContent {
      
        @Comment("系统公告")
        public transient static final short TYPE = OBJ_SYSNOTICE_MESSAGE;
        
        @Column(length = 128, comment = "系统公告id ‘createuserid + time36’")
        private String sysnoticeid = "";

        @Column(length = 64, comment = "通知标题")
        private String title = "";

        @Column(comment = "通知 对象  1 2 4 （1 新用户 2 老用户 4 全员)")
        private short noticetarget;

        @Column(length = 2000, comment = "通知内容")
        private String content = "";

        
        @Column(comment = "10 开启 20 关闭")
        private short status = 10;

        @Column(updatable = false, comment = "创建时间")
        private long createtime;
        

        public static final short OPEN_STATUS = 10;
        
        public static final short CLOSE_STATUS = 20;
		public String getSysnoticeid() {
			return sysnoticeid;
		}


		public void setSysnoticeid(String sysnoticeid) {
			this.sysnoticeid = sysnoticeid;
		}


		public String getTitle() {
			return title;
		}


		public void setTitle(String title) {
			this.title = title;
		}


		public short getNoticetarget() {
			return noticetarget;
		}


		public void setNoticetarget(short noticetarget) {
			this.noticetarget = noticetarget;
		}


		public String getContent() {
			return content;
		}


		public void setContent(String content) {
			this.content = content;
		}


		public short getStatus() {
			return status;
		}


		public void setStatus(short status) {
			this.status = status;
		}


		public long getCreatetime() {
			return createtime;
		}


		public void setCreatetime(long createtime) {
			this.createtime = createtime;
		}
		

		public void setNotice(SystemNotice notice) {
                        setContent(notice.getContent());
                        setCreatetime(notice.getCreatetime());
                        setNoticetarget(notice.getNoticetarget());
                        setContent(notice.getContent());
                        setTitle(notice.getTitle());
                        setStatus(notice.getStatus());
                        setSysnoticeid(notice.getSysnoticeid());
		}
                
                public static SysNoticeMessage create(SystemNotice notice) {
                    SysNoticeMessage message = new SysNoticeMessage();
                    message.setContent(notice.getContent());
                    message.setCreatetime(notice.getCreatetime());
                    message.setNoticetarget(notice.getNoticetarget());
                    message.setContent(notice.getContent());
                    message.setTitle(notice.getTitle());
                    message.setStatus(notice.getStatus());
                    message.setSysnoticeid(notice.getSysnoticeid());
                    return message;
		}
                
                public SysNoticeMessage copyLastNotice(SystemUserNotice lastNotice) {
                    SysNoticeMessage message = new SysNoticeMessage();
                    message.setContent(this.getContent());
                    message.setCreatetime(this.getCreatetime());
                    message.setNoticetarget(this.getNoticetarget());
                    message.setContent(this.getContent());
                    message.setTitle(this.getTitle());
                    message.setStatus(this.getStatus());
                    message.setSysnoticeid(this.getSysnoticeid());
                    message.setExtra(create(lastNotice));
                    return message;
		}
                
        
   }
    
    @Comment("消息合并转发")
    public static final class  MerageForwordMessage extends BasicContent {
    
    	@Comment("消息合并转发")
        public transient static final short TYPE = OBJ_MERAGE_FROWORDMESSAGE;
    	
    	List<MessageRecordExt> records;
    	
    	public List<MessageRecordExt> getRecords() {
			return records;
		}

		public void setRecords(List<MessageRecordExt> records) {
			this.records = records;
		}

		@Comment("消息转发内容")
    	public static final class MessageRecordExt extends MessageRecord {
    		/**
			 * 
			 */
			private static final long serialVersionUID = -4684371370537901518L;
			
			@Comment("发送用户名")
			private String fromUserName;
			
			@Comment("发送用户头像")
    		private String fromUserFace;
			
			public String getFromUserName() {
				return fromUserName;
			}
			public void setFromUserName(String fromUserName) {
				this.fromUserName = fromUserName;
			}
			public String getFromUserFace() {
				return fromUserFace;
			}
			public void setFromUserFace(String fromUserFace) {
				this.fromUserFace = fromUserFace;
			}
    		
    	}
    }
}
